<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/jsp/common/common.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
	<head>	
		<title>工作计划</title>
		<script type="text/javascript" src="<%=contextPath%>/js/jquery.autogrow.js"></script> 
		<script type="text/javascript" src="<%=contextPath%>/js/validator.js"></script>
		<script type="text/javascript" src="<%=contextPath%>/js/My97DatePicker/WdatePicker.js"></script>
		<script type="text/javascript">
			Ext.onReady(function(){
				var tb = new Ext.Toolbar({
			   		renderTo: document.all.tbar,
			    	items: [
				       {
				            text: '保存',
				            icon:"<%=contextPath%>/images/save.gif",
				            hidden:<%=session.getAttribute("btn_add_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")) ? false:true%>,
				            handler:function(){
				            	comt();
				            }
				        },'-',
				        {
		            text: '提交',
		            icon:"<%=contextPath%>/" + "images/pass.gif",
		            hidden:<%=session.getAttribute("btn_add_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")) ? false:true%>,
		            handler:function() {
		            	toConfirm('1');
		            }
	        	},'-',
				        {
				            text: '返回',
				            icon:"<%=contextPath%>/images/fanhui.png",
				            handler:function(){
				            	back();
				            }
				        }
			    	]
			    });
			});
			$(document).ready (function() {
			
			$('textarea').autogrow();		
		});
			function getprojectinfo(){
			window.open("<%=contextPath%>/projectImplement!findByUnitno.do", '统计表格', 'height=800, width=350, top=200, left=300, toolbar=no, menubar=no');
			// document.frmM.action = "<%=contextPath%>/projectImplement!findByUnitno";
			}
			function getprojectinfo(){
			window.open("<%=contextPath%>/projectImplement!findByUnitno.do", '统计表格', 'height=800, width=350, top=200, left=300, toolbar=no, menubar=no');
			// document.frmM.action = "<%=contextPath%>/projectImplement!findByUnitno";
			}
			function getXSRQ(){
			var bdzName=document.getElementById("stationname").value;
			var objG=document.getElementById("xsrq");
			objG.options.length=1;
			//objG.options[objG.options.length] = new Option("请选择",""); 			
			Ext.Ajax.request({
					method :'POST',
					url :'plan!getXSRQ.do',
					params : {
						"entity.stationname": bdzName						
					},
					success : function(response, options) { 						
						var rtn = Ext.decode(response.responseText);
						
						// 基本信息参数
						for (var p in rtn) {
							try {
								if(rtn[p].itemid){
								var varItem = new Option(rtn[p].itemid,rtn[p].itemname);
								objG.options[objG.options.length] = varItem ;  
								}
							} catch (e){
							alert("链接变电运行系统失败");
							}
						}
						
						
					},
					failure : function() {
						Ext.MessageBox.alert('提示 ', '提取数据失败！');
					}
				});
				}
		</script>
	</head>
  
  <body topmargin="0">
  <div id = "tbar"></div>
  <center>
			<!-- 信息提示 -->
			<div result><font color="red">${info }</font></div>
		</center>
 		<form id="frmM" class="ct" name="frmM" method="POST" action="<%=contextPath%>/projectImplement!save.do">
 			<input type="hidden" id="hiddenids" name="hiddenids" value="${hiddenids}"/>
 			<input type="hidden" name="searchBean.con6" id="searchBean.con6" value="${searchBean.con6}" >
 			<s:hidden name="entity.plantype" />	
			<s:hidden name="entity.id" />	
			<s:hidden name="entity.ouid" />
			<s:hidden name ="entity.dwry"/>	
			<s:hidden name ="entity.ysr"/>	
			<s:hidden name ="entity.fzr"/>
			<s:hidden name="entity.status" />
			<s:hidden name="entity.phbz"/>	
			<table width="100%"  id="infotab" >
			<tr>
					<th align="left" ><font color="red">*</font>变电站：</th>
					<td>
					<!--	<s:select list="bdzList" name="entity.stationid" width="300" listKey="id" listValue="bdzname"/>
							
						<input type="text" readonly="true" style="width:95%" datatype="Require" name="entity.stationname" value="${entity.stationname}" msg="变电站必须输入。" size="25"/>
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="选择变电站" onClick="javascript:getBdzjx('entity.stationid','entity.stationname')" />
						<input type="hidden" name="entity.stationid" value="${entity.stationid}"/>-->
						<s:hidden name="entity.stationid"/>
						<input type="text" readonly="true" datatype="Require" onpropertychange="getXSRQ();" id="stationname" name="entity.stationname" value="${entity.stationname}" msg="变电站必须输入。" />
						<img src="<%=contextPath%>/images/editlink.gif" title="选择变电站" onClick="javascript:getBdzselect('entity.stationid','entity.stationname')" />
		</td>
		<td colspan="2">
		<table><tr>
			<th width="120" nowrap>
						工作票类别：
					</th>
					 <td>
					<select name="entity.category" datatype="Require" msg="工作票类别必须输入。" onchange="setEndCheck()">
							<c:choose>
								<c:when test="${entity.category == '' || entity.category == null}">
									<option value="" selected></option>
									<option value="1">一种票</option>
									<option value="2">二种票</option>
								</c:when>
								<c:when test="${entity.category == '1'}">
									<option value="" ></option>
									<option value="1" selected>一种票</option>
									<option value="2">二种票</option>
								</c:when>
								<c:when test="${entity.category == '2'}">
									<option value="" ></option>
									<option value="1">一种票</option>
									<option value="2" selected>二种票</option>
								</c:when>
							</c:choose>
						</td>
						<th width="120" >
						<font color="red"></font>&nbsp;工程建设：
					</th>
					<td><% if ((session.getAttribute("btn_gcjs_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")))) {%>
						<select name="entity.gcjs"  msg="" >
							<c:choose>
								<c:when test="${entity.gcjs == '' || entity.gcjs == null}">
									<option value="" selected></option>
									<option value="1">是</option>
									<option value="2">否</option>
								</c:when>
								<c:when test="${entity.gcjs == '1'}">
									<option value="" ></option>
									<option value="1" selected>是</option>
									<option value="2">否</option>
								</c:when>
								<c:when test="${entity.gcjs == '2'}">
									<option value="" ></option>
									<option value="1">是</option>
									<option value="2" selected>否</option>
								</c:when>
							</c:choose><%} else {%>
							<c:choose>
							<c:when test="${entity.gcjs == '' || entity.gcjs == null}">否</c:when>
						    <c:when test="${entity.gcjs == '1'}">是</c:when>
                            <c:when test="${entity.gcjs == '2'}">否</c:when>	
                            </c:choose>				
						<%}%>
					</td>
					</td></tr></table>
				</tr>
				<tr>
				<th align="left" >停电范围：</th>
				<td colspan="3" >
				<textarea name=entity.powerrange style="width:99%; height: 30px; min-height: 20px;line-height:15pt"  datatype="LimitB"  min="0"   max="200"   maxlength="50" size="25"  msg="一种票停电范围必须输入。">${entity.powerrange}</textarea>
				</td>	
				</tr>
				<tr>
				<th width="120" nowrap>
					<font color="red">*</font>开始时间：
					</th>
					<td>
						<input type="text" datatype="Require" onclick="WdatePicker({el:$dp.$('entity.startdate'),maxDate:'#F{$dp.$D(\'entity.enddate\')}'})" name="entity.startdate" readonly="true" value='<fmt:formatDate value="${entity.startdate}" pattern="yyyy-MM-dd HH:mm"/>' msg="开始时间必须输入。"/>
						<img onclick="WdatePicker({el:$dp.$('entity.startdate'),maxDate:'#F{$dp.$D(\'entity.enddate\')}'})" src="<%=contextPath%>/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
					<select id="xsrq" name="xsrq">
						<option value="">巡视日期参考</option>
						</select>
                         </td>
				    <th width="120" nowrap>
				<font color="red">*</font>	结束时间：
					</th>
					<td>
						<input type="text"  datatype="Require" onclick="WdatePicker({el:$dp.$('entity.enddate'),minDate:'#F{$dp.$D(\'entity.startdate\')}'})" name="entity.enddate" readonly="true" value='<fmt:formatDate value="${entity.enddate}" pattern="yyyy-MM-dd HH:mm"/>' msg="结束时间必须输入。"/>
						<img onclick="WdatePicker({el:$dp.$('entity.enddate'),minDate:'#F{$dp.$D(\'entity.startdate\')}'})" src="<%=contextPath%>/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
					</td>
				</tr>
				
				<tr>
					<th width="120" nowrap>
						总工作负责人：
					</th>
					<td>
						<!--<input type="text" style="width:50%" readonly="true" name="entity.responsible" value="${entity.responsible}" msg="负责人必须输入。"/>
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getUser('entity.fzr','entity.responsible','entity.bdz')" />
						-->
						<input type="text" style="width:50%" datatype="Require" readonly="true" name="entity.responsible" value="${entity.responsible}" msg="总工作负责人必须输入。"/>
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getUserselect('entity.fzr','entity.responsible')" />
				
					</td>
					<th width="120" nowrap>
						施工方案：
					</th>
					<!--  <td>
						<c:if test="${entity.id != '0'}">
							<img style='cursor:pointer' onclick="filePopup('${entity.id}','TAB_PLAN_SGFA','0')" alt="打开附件列表" src="<%=contextPath%>/images/userfile.png" >
						</c:if>
						<c:if test="${entity.id == '0'}">
							&nbsp;<img src="<%=contextPath%>/images/redlight.gif"/><font color="red">请保存记录后上传录音</font>
						</c:if>
					</td>-->
					 <td>
					<select name="entity.sgfa" >
									<c:choose>
								<c:when test="${entity.sgfa == '' || entity.sgfa == null}">
									<option value="" selected></option>
									<option value="0">否</option>
									<option value="1">是</option>
								</c:when>
								<c:when test="${entity.sgfa == '0'}">
									<option value="" ></option>
									<option value="0" selected>否</option>
									<option value="1">是</option>
								</c:when>
								<c:when test="${entity.sgfa == '1'}">
									<option value="" ></option>
									<option value="0">否</option>
									<option value="1" selected>是</option>
								</c:when>
							</c:choose>
									</td>
				</tr>
				<!--  <tr>
					<th align="left" >停电范围：</th>
					<td>
						</td>
					<th>设备类型</th>
					<td>
						<s:select list="sblxList" name="entity.sblx" width="300" listKey="itemId" listValue="itemName"/>
				</tr>-->
				<tr>
					<th width="120" nowrap>
						验收人：
					</th>
					<td>
						<input type="text" style="width:50%" readonly="true" name="entity.ysrname" value="${entity.ysrname}" msg="验收人必须输入。"/>
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getUser('entity.ysr','entity.ysrname')" />
					</td>
					<th width="120" nowrap>
						到位人员：
					</th>
					<td>
						
						<input type="text" style="width:50%" readonly="true" name="entity.dwryname" value="${entity.dwryname}" msg="到位人员必须输入。"/>
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getUser('entity.dwry','entity.dwryname','entity.bdz')" />
						
					</td>
				</tr>
			    <tr>
					<th width="120" nowrap>
						<font color="red"></font>&nbsp;配合班组：
					</th>
					<td>
						<input type="text" style="width:50%" readonly="true" name="entity.phbzname" value="${entity.phbzname}" msg="配合班组必须输入。" />
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getBz('entity.phbz','entity.phbzname','searchBean.con7')" />
						</td>
					<th width="120" nowrap>
						&nbsp;配合工作日期：
					
					</th>
					<td>
						
				       <input type="text" name="entity.phgzdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',el:$dp.$('entity.phgzdate'),maxDate:'#F{$dp.$D(\'entity.enddate\')}',minDate:'#F{$dp.$D(\'entity.startdate\')}'})" readonly="true" value='<fmt:formatDate value="${entity.phgzdate}" pattern="yyyy-MM-dd"/>' maxlength="50" size="9" msg="配合工作日期必须输入。" />
				        <img onclick="WdatePicker({dateFmt:'yyyy-MM-dd',el:$dp.$('entity.phgzdate'),maxDate:'#F{$dp.$D(\'entity.enddate\')}',minDate:'#F{$dp.$D(\'entity.startdate\')}'})" src="<%=contextPath%>/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
				    
					</td>
				</tr>
				
				<tr>
					<th align="left" >&nbsp;工作项目：</th>
					<td colspan="3" >
						<textarea name="entity.workcontent" readonly="readonly" style="width:99%; height: 30px; min-height: 20px;line-height:15pt" min="0" datatype="LimitB"     max="2000"  datatype="Require"  msg="工作项目必须输入。" >${entity.workcontent}</textarea></td>
				</tr>
				<tr>
					<th align="left" >备注： </th>  
					<td colspan="3" >
						<textarea name="entity.remarks" style="width:99%; height: 30px; min-height: 20px;line-height:15pt" min="0" datatype="LimitB"  min="0"   max="200"   maxlength="50" size="25"  >${entity.remarks}</textarea></td>
				</tr>
				<% if ("0".equals(session.getAttribute("SESSION_ISADMIN"))) {%>
				<tr>
					<th width="120" nowrap>
						录入人员：
					</th>
					<td>
						<s:hidden name="entity.cjrid"/>
						<input type="text" style="width:120" readonly="true" name="entity.cjr" value="${entity.cjr}" msg="录入人员必须输入。"/>
					</td>
					<th width="120" nowrap>
						录入时间：
					</th>
					<td>
						<input type="text" size="12" name="entity.cjsj" readonly="true" value='<fmt:formatDate value="${entity.cjsj}" pattern="yyyy-MM-dd HH:mm"/>' msg="巡视结束时间必须输入。"/>
					</td>
					
				</tr>
				<%} else {%>
				<tr>
					<th width="120" nowrap>
						录入人员：
					</th>
					<td>
						<s:hidden name="entity.cjrid"/>
						<input type="text" style="width:120" readonly="true" name="entity.cjr" value="${entity.cjr}" msg="录入人员必须输入。"/>
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getUser('entity.cjrid','entity.cjr','entity.bdz')" />
					</td>
					<th width="120" nowrap>
						录入时间：
					</th>
					<td>
						<input type="text" size="12" onclick="WdatePicker({el:$dp.$('entity.cjsj')})" name="entity.cjsj" readonly="true" value='<fmt:formatDate value="${entity.cjsj}" pattern="yyyy-MM-dd HH:mm"/>' msg="巡视结束时间必须输入。"/>
						<img onclick="WdatePicker({el:$dp.$('entity.cjsj')})" src="<%=contextPath%>/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
					</td>
					
				</tr>
				<%}%>
		<!-- 	<tr>
					<th width="18%" align="left" class="ct"> &nbsp;隔日日期：</th>
					<td width="31%" >
				    	 <s:textfield name="entity.gr" readonly="true" maxlength="50" size="25"  />
				    	 <img onclick="WdatePicker({dateFmt:'yyyy-MM-dd',el:$dp.$('entity.gr')})" src="<%=contextPath%>/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
				     </td>
					<th width="18%" align="left" class="ct"> &nbsp;第一日日期：</th>
					<td width="31%" >
				    	 <s:textfield name="entity.dyr" readonly="true" maxlength="50" size="25"  />
				    	 <img onclick="WdatePicker({dateFmt:'yyyy-MM-dd',el:$dp.$('entity.dyr')})" src="<%=contextPath%>/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
				     </td>
				</tr> -->
			<hr>
			<table width="100%" id="listtab" class = "leadertab" >
				<tr><td colspan="6"> 工作组织 </td></tr>
				<tr>
					<th width="60">班组</th>
					<th width="100">负责人</th>
					<th width="200">成员</th>
					<th width="50" nowrap>
						临时用工人数
					</th>
					<th>工作任务</th>
					<th width="20"></th>
				</tr>

				<c:forEach items="${planbzList}" var="detail" varStatus="status">
					<tr id='tr${status.index}' class = "repeat">
						<td width="90" >
							<input type="hidden" id="planbzList[${status.index}].planid" name="planbzList[${status.index}].planid" value = "${detail.planid}"/>
							<input type="hidden" id="planbzList[${status.index}].id" name="planbzList[${status.index}].id" value = "${detail.id}"/>
							<input type="hidden" id="planbzList[${status.index}].delflag" name="planbzList[${status.index}].delflag" value = "${detail.delflag}"/>
							<input type="hidden" id="planbzList[${status.index}].bzid" name="planbzList[${status.index}].bzid" value = "${detail.bzid}"/>
							<input type="text" readonly="true" style="width:90%" id="planbzList[${status.index}].bzname" name="planbzList[${status.index}].bzname" value = "${detail.bzname}"/>
						</td>
						<td width="100">
							<input type="hidden" id="planbzList[${status.index}].fzrid" name="planbzList[${status.index}].fzrid" value = "${detail.fzrid}"/>
							<input type="text" readonly="true" style="width:80%" id="planbzList[${status.index}].fzrname" name="planbzList[${status.index}].fzrname" value = "${detail.fzrname}"/>
							<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getUser('planbzList[${status.index}].fzrid','planbzList[${status.index}].fzrname','detail.bzid')" />
						</td>
						<td width="200">
							<input type="hidden" id="planbzList[${status.index}].cyid" name="planbzList[${status.index}].cyid" value = "${detail.cyid}"/>
							<input type="text" readonly="true" style="width:80%" id="planbzList[${status.index}].cyname" name="planbzList[${status.index}].cyname" value = "${detail.cyname}"/>
							<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getUser('planbzList[${status.index}].cyid','planbzList[${status.index}].cyname','detail.bzid')" />
						</td>
						
					<td width="50">
						<input type="text" style="width:30px" datatype="Number" maxlength="3" name="planbzList[${status.index}].lsygrs" id="planbzList[${status.index}].lsygrs" value = "${detail.lsygrs}" msg="临时用工人数必须输入数字。"/>
					</td>
						<td nowrap="nowrap">
						<textarea id="planbzList[${status.index}].gzrw" name="planbzList[${status.index}].gzrw"  style="width:99%; height: 30px; min-height: 20px;line-height:15pt" min="0" datatype="LimitB"   max="2000" readonly="true"   msg="工作任务最大1000个汉字。" >${detail.gzrw}</textarea>
				                
						</td>
						<td width="20">
						<c:if test="${detail.planid != '0'}">	
								<img src="<%=contextPath%>/images/pass.gif" onclick = "toNewRwd(${detail.bzid},${detail.planid},${entity.stationid},${fn:length(planbzList)})" style="cursor:pointer"/>
								</c:if>
					   </td>
					</tr>
				</c:forEach>
			
			</table>
		</table>
   </form>
  </body>
</html>
<script language="javascript">
	 // 保存
     function comt(){
        if(!Validator.Validate(frmM,1)){
			return false;
		}
     	document.frmM.action = "<%=contextPath%>/plan!saveMonthPlan.do";
     	document.frmM.submit();
     }
     
     // 返回
     function back() {
        location.href = "<%=contextPath%>/planList!getList.do?"
     }
 // 附件列表
	 function filePopup(id,colname,imageflag) {
		 var url = "<%=contextPath%>/jsp/common/fileTab.jsp?tableid=" + id + "&colname="+colname+"&imageflag="+imageflag;// "<%=contextPath%>/sb!test.do?id="+id;
		 var win = window.open(url,"图片列表","left=450,top=30,width=850,height=500,status=no,toolbar=no,autoscroll=yes,location=no,menubar=no,resizable=yes",true);
	}
		// 批准, 审核
		function toConfirm(flag)
		{
		 if(!Validator.Validate(frmM,1)){
			return false;
		}
				var msg = flag == '1' ? '提交':'审核通过';
				
		    	if(confirm("确定要" + msg + "选中的记录吗？")) {
		        	document.frmM.action = "<%=contextPath%>/plan!saveMonthPlan.do?flag=" + flag;
					document.frmM.submit();
		    	}
		}
		// 起草计划班组工作任务
		function toNewRwd(paramBzid,paramPlanid,paramBdzid,paramBzlength){
		//window.alert(paramBzid);window.alert(paramPlanid);
		// 打开窗口
		//parent.addTab("班组工作任务", "<%=contextPath%>/jsp/business/plan/bzgzrw.jsp?paramBzid="+paramBzid+"&paramPlanid="+paramPlanid+"&paramBzlength="+paramBzlength, paramBzid);
    var url = "<%=contextPath%>/jsp/business/plan/bzgzrw.jsp?paramBzid="+paramBzid+"&paramPlanid="+paramPlanid+"&paramBdzid="+paramBdzid+"&paramBzlength="+paramBzlength;
		 var win = window.open(url,"计划任务列表","left=150,top=30,width=1280,height=768,status=no,toolbar=no,autoscroll=yes,location=no,menubar=no,resizable=yes",true);
	
				}
				// 停电范围的验证 by wangtao add20120605
		function setEndCheck() {
			if (document.getElementById("entity.category").value == '1') {
					document.getElementById("entity.powerrange").min="1";
		    }else{
		    document.getElementById("entity.powerrange").min="0";
		    }
		    }
</script>
